package com.mumulx.check;

import com.mumulx.check.redis.entity.CheckPartContants;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.amqp.core.Queue;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

/*
 *  Created by IntelliJ IDEA.
 *  User: 木木
 *  Date: 2020/10/28
 *  Time: 20:39
 */
@SpringBootApplication//在服务启动后自动注册到eureka
@EnableEurekaClient
@EnableDiscoveryClient//服务发现
@EnableCircuitBreaker//增加对熔断的支持
public class NXRemoteServerProvider8001 {
    public static void main(String[] args) {
        SpringApplication.run(NXRemoteServerProvider8001.class, args);
    }

    @Bean
    public ServletRegistrationBean getServlet() {
        HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
        registrationBean.setLoadOnStartup(1);
        registrationBean.addUrlMappings("/actuator/hystrix.stream");
        registrationBean.setName("HystrixMetricsStreamServlet");
        return registrationBean;
    }


    @Bean
    Queue queue() {
        return new Queue(CheckPartContants.MAIL_QUEUE_NAME);
    }

}
